package com.lanou.managerLogin.category.service;

import com.lanou.managerLogin.category.dao.CategoryDao;
import com.lanou.managerLogin.category.dao.CategoryDaoImpl;
import com.lanou.managerLogin.category.domain.Category;

import java.util.ArrayList;
import java.util.List;

public class CategoryService {

    private CategoryDao cd = new CategoryDaoImpl();

    public List<Category> selCname() {
        List<Category> categories = cd.selectCname();
        if (categories.size() == 0) {
            System.out.println("啥也没有");
        } else {
            return categories;
        }
        return new ArrayList<>();
    }

    public void updateCategory(String cid, String cname) {
        cd.updateCname(cid, cname);
    }

    public void deleteCategory(String cid) {
        cd.deleteCname(cid);
    }

    public void insertCategory(String cname) {
        cd.insertCname(cname);
    }

    public Category cateCname(String cid) {
        Category category = cd.cateCname(cid);
        if (category == null) {
            System.out.println("啥也没有");
        } else {
            return category;
        }
        return new Category();
    }


}
